#include <iostream>
using namespace std;
class Data
{
public:
   int a,b,c;
   void print() const {
    cout << "a=" << a << ",b="<<b<<",c="<<c <<endl;
   }
};

class Widget{
    void f(int) const {
        cout <<"f"<<endl;
    }
    void g(int) const {
        cout <<"g"<<endl;
    }
    void h(int) const {
        cout <<"h"<<endl;
    }
    void i(int) const {
        cout <<"i"<<endl;
    }
    enum {
        cnt =4
    };
    void (Widget:: *fptr[cnt])(int) const;
    public:
    Widget(){
        fptr[0]=&Widget::f;
        fptr[1]=&Widget::g;
        fptr[2]=&Widget::h;
        fptr[3]=&Widget::i;
    }
    void select(int i,int j){
        if(i<0 || i>=cnt) return;
        (this->*fptr[i])(j);
    }
    int count(){
        return cnt;
    }
};
int main(){
    Data d ,*dp =&d;
    int Data::* pmInt =&Data::a;
    dp ->*pmInt=47;

    pmInt =&Data::b;
    d.*pmInt=48;
     
    pmInt =&Data::c;
    dp ->*pmInt=49;

    dp ->print();
    Widget w;
    for(int i=0;i<w.count();i++)
      w.select(i,47);
}

